g <-
ggplot(iris) +
aes(
x = Sepal.Length,
y = Sepal.Width,
color = Species
) +
geom_point() +
theme_classic()
gg +
theme(
legend.position = "top"
)g +
theme(
legend.position = "bottom"
)g +
theme(
legend.position = "left"
)g +
theme(
legend.position = "left"
) +
labs(
color = "hello"
)g +
theme(
legend.position = "left"
) +
labs(
color = ""
)לא מוכן
#g +
# theme(
# legend.position = "left",
# legend.key.height= unit(10, 'cm'),
# legend.key.width= unit(10, 'cm')
# ) +
# labs(
# color = ""
# )
#לא מוכן
g +
theme(
legend.box = "vertical"
) +
labs(
color = ""
)g +
theme(
legend.box = "horizontal"
) +
labs(
color = ""
)g +
theme(
legend.text =
element_text(
size=20
)
) +
labs(
color = ""
)g +
labs(
color = ""
) +
guides(
color =
guide_legend(
label.position = "top",
nrow = 1
)
)g +
labs(
color = ""
) +
guides(
color =
guide_legend(
label.position = "top",
)
)g +
labs(
color = ""
) +
guides(
color =
guide_legend(
label.position = "top",
nrow = 1
)
) +
theme(
legend.justification = c("right", "top")
)g +
labs(
color = ""
) +
guides(
color =
guide_legend(
label.position = "top",
nrow = 1
)
) +
theme(
legend.justification = c("bottom")
)g +
labs(
color = ""
) +
guides(
color =
guide_legend(
label.position = "top",
nrow = 1
)
) +
theme(
legend.position = "top",
legend.justification = c("left")
)g +
labs(
color = ""
) +
guides(
color =
guide_legend(
label.position = "top",
nrow = 1
)
) +
theme(
legend.position = "top",
legend.justification = c("left")
)gg <-
ggplot(iris) +
aes(
x = Sepal.Length,
y = Sepal.Width,
color = Species,
size = Sepal.Length
) +
geom_point() +
theme_classic()
gggg +
labs(
color = "",
size = ""
)gg +
labs(
color = "",
size = ""
) +
guides(
color =
guide_legend(
label.position = "top",
nrow = 1
),
size =
guide_legend(
label.position = "top",
nrow = 1
)
) +
theme(
legend.position = "right"
)gg +
labs(
color = "",
size = ""
) +
guides(
color =
guide_legend(
label.position = "top",
nrow = 1
),
size =
guide_legend(
label.position = "top",
nrow = 1
)
) +
theme(
legend.position = "right",
legend.box = "horizontal"
)gg +
labs(
color = "",
size = ""
) +
guides(
color =
guide_legend(
label.position = "top",
nrow = 1
),
size =
guide_legend(
label.position = "top",
nrow = 1
)
) +
theme(
legend.position = "top",
legend.box = "horizontal"
)gg +
labs(
color = "",
size = ""
) +
guides(
color =
guide_legend(
label.position = "top",
nrow = 1
),
size =
guide_legend(
label.position = "top",
nrow = 1
)
) +
theme(
legend.position = "top",
legend.justification = c("left"),
legend.box = "horizontal"
)gg +
labs(
title = "title",
subtitle = "subtitle",
color = "color",
size = "size"
) +
guides(
color =
guide_legend(
label.position = "bottom",
nrow = 1,
title.position = "top"
),
size =
guide_legend(
label.position = "bottom",
nrow = 1,
title.position = "top"
)
) +
theme(
legend.position = "top",
legend.justification = c("right"),
legend.box = "horizontal"
)gg +
labs(
title = "title",
subtitle = "subtitle",
color = "color",
size = "size"
) +
guides(
color =
guide_legend(
label.position = "bottom",
nrow = 1,
title.position = "top"
),
size =
guide_legend(
label.position = "bottom",
nrow = 1,
title.position = "top"
)
) +
theme(
legend.position = c(0.99, 1.04),
legend.justification = c("right"),
legend.box = "horizontal"
)gg +
labs(
title = "title",
subtitle = "subtitle",
color = "",
size = ""
) +
guides(
color =
guide_legend(
label.position = "bottom",
nrow = 1,
title.position = "top"
),
size =
guide_legend(
label.position = "bottom",
nrow = 1,
title.position = "top"
)
) +
theme(
legend.spacing = unit(0, "cm"),
legend.margin = margin(),
legend.position = c(1.01, 1.09),
legend.justification = c("right"),
legend.box = "horizontal"
)g +
theme(
legend.background =
element_rect(
fill="lightblue",
size=0.5,
linetype="solid"
)
)g +
theme(
legend.background =
element_rect(
fill = "lightblue",
size = 0.5,
linetype = "solid",
colour = "darkblue"
)
)gg +
theme(
legend.box.background = element_rect(color="red", size=2),
legend.box.margin = margin(6, 6, 6, 6)
)gg +
theme(
legend.key =
element_rect(
fill = "springgreen",
colour = "black"
)
)בלי פקודת סדר:
gg +
labs(
title = "title",
subtitle = "subtitle",
color = "",
size = ""
) +
guides(
color =
guide_legend(
label.position = "bottom",
nrow = 1,
title.position = "top"
),
size =
guide_legend(
label.position = "bottom",
nrow = 1,
title.position = "top"
)
) +
theme(
legend.position = c(1.01, 1.09),
legend.justification = c("right"),
legend.box = "horizontal"
)שינוי הסדר
gg +
labs(
title = "title",
subtitle = "subtitle",
color = "",
size = ""
) +
guides(
color =
guide_legend(
order = 1,
label.position = "bottom",
nrow = 1,
title.position = "top"
),
size =
guide_legend(
order = 2,
label.position = "bottom",
nrow = 1,
title.position = "top"
)
) +
theme(
legend.position = c(1.01, 1.09),
legend.justification = c("right"),
legend.box = "horizontal"
)גרף:
gg מחיקת גודל
gg +
guides(
size = FALSE
)